package com.jumper.property.comparer.core.diff.value;


import com.jumper.property.comparer.core.diff.Diff;
import com.jumper.property.comparer.core.diff.DiffVal;
import com.jumper.property.comparer.core.util.StringUtils;
import com.jumper.property.comparer.core.formatter.ObjectDisplayNameDiffFormatter;

import java.util.ArrayList;
import java.util.List;

public class SubjectDiff implements Diff {

    private final String displayNames;

    public SubjectDiff(String displayNames) {
        this.displayNames = displayNames;
    }

    @Override
    public List<DiffVal> getDiffValues() {
        List<DiffVal> diffValList = new ArrayList<>();
        if (!StringUtils.isEmpty(displayNames)) {
            diffValList.add(new DiffVal(
                    displayNames, displayNames, getDiffValue()
            ));
        }
        return diffValList;
    }

    private String getDiffValue() {
        return new ObjectDisplayNameDiffFormatter(displayNames).format();
    }
}
